import 'package:flutter/material.dart';

class Page1 extends StatelessWidget {
  const Page1({super.key});

  @override
  Widget build(BuildContext context) {
    return  Scaffold(
        body: GestureDetector(//手势监听点击
          child: const Hero(
              tag: 'hero',//设置共享tag
              child: SizedBox(
                  width: 100, height: 100,
                  child: FlutterLogo()
              )
          ),
          onTap: () {
            Navigator.of(context).push(MaterialPageRoute(builder: (_)=>const Page2()));//点击后打开第二个页面
          },
        )
    );
  }
}

class Page2 extends StatelessWidget {
  const Page2({super.key});

  @override
  Widget build(BuildContext context) {
    return  Scaffold(
        appBar: AppBar(title: const Text("Page2")),
        body: const Hero(
          tag: 'hero',//设置共享tag
          child: Center(
              child: SizedBox(
                  width: 300, height: 300,
                  child: FlutterLogo()
              )),
        )
    );
  }
}